#include <iostream>
#include <initializer_list>
// 创建一个处理任何参数类型的模板类
template <typename T>
T everage(std::initializer_list<T> il) {
    T sum = 0;
    for(auto i = il.begin(); i != il.end(); i ++) {
        std::cout << "第" <<i - il.begin() <<  "个" << "数据是: " << *i << "\n";
        sum += *i;
    }
    T result = sum / il.size();
    return result;
}

class Dump{
    public:
        Dump(int r, int w):roots(r), weights(w){

        }
        void showRoots(){
            std::cout << roots << std::endl;
        }
        void showWeights() {
            std::cout << weights << std::endl;
        }
    private:
        int roots;
        int weights;
};

int main_main(int argc, char const *argv[])
{
    Dump d1{10, 20};
    Dump d2 = {30, 40};
    d1.showRoots();
    d2.showRoots();
    auto result = everage({3, 2, 1});
    std::cout << result << std::endl;

    return 0;
}
